/*
 *  (C) Copyright 2007 Insula Tecnologia da Informacao Ltda.
 * 
 *  This file is part of Jazz.
 *
 *  Jazz is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Jazz is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Jazz.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.jazz.resolver.swing;

import static org.junit.Assert.assertEquals;

import javax.swing.JComboBox;

import org.junit.Test;

public class DefaultJComboBoxResolverTestCase {

	private JComboBox comboBox = new JComboBox(new String[] { "banana", "apple", "peach" });

	private DefaultJComboBoxResolver resolver = new DefaultJComboBoxResolver();

	@Test
	public void testGetValue() {
		comboBox.setSelectedItem("apple");
		assertEquals("apple", resolver.getValue(comboBox));
		comboBox.setSelectedIndex(2);
		assertEquals("peach", resolver.getValue(comboBox));
	}

	@Test
	public void testSetValue() {
		resolver.setValue(comboBox, "banana");
		assertEquals(0, comboBox.getSelectedIndex());
		resolver.setValue(comboBox, "apple");
		assertEquals(1, comboBox.getSelectedIndex());
	}

}
